<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LinkDao
 *
 * @author Binh
 */
class LinkDao {
    public static function getLinks() {
        $ds = array();
        $sql = "select * from links where deleted=0";
        $helper = new MySqlDataAccessHelper;

        //$helper->open();
        $rs = $helper->executeQuery($sql);
        if (FALSE === $rs) {
            echo mysql_error();
            return $ds;
        } else {
            while ($row = mysql_fetch_array($rs)) {
                $obj = new Links($row["id"],$row["name"],$row["link"]);
                array_push($ds, $obj);
            }
            //$helper->close();
            return $ds;
        }
    }
    public static function insertLink($name, $link) {
        $sql = sprintf("INSERT INTO links (name, link) Values('%s', '%s')", $name, $link);
        $helper = new MySqlDataAccessHelper;

        $helper->open();
        $helper->executeUpdate($sql);
        $helper->close();
    }
}

?>
